//元件功能：可配置延迟周期数和数据位宽的移位寄存器，主要用作延迟
module shift_regs_xtap#(
parameter DWIDTH     = 8,//数据位宽
parameter DISTANCE   = 256,//tap之间的间距
parameter TAPS_NUM   = 3
)(
     input                        clk,
	 input                        rst_n,
	 input [DWIDTH-1:0]           idata,
	 output [DWIDTH*TAPS_NUM-1:0] taps,
	 output [DWIDTH-1:0]          odata
);

reg [DWIDTH-1:0] idata_r[TAPS_NUM*DISTANCE-1:0];
genvar i;
generate
for(i=0; i<TAPS_NUM*DISTANCE-1; i=i+1)
    begin:u0
	 always@(posedge clk or negedge rst_n)
	     if(!rst_n)
		      idata_r[i+1] <= 'd0;
		  else
				idata_r[i+1] <= idata_r[i];
	 end
endgenerate
always@(posedge clk or negedge rst_n)
if(!rst_n)
    idata_r[0] <= 'd0;
else
    idata_r[0] <= idata;
	 
assign odata = idata_r[TAPS_NUM*DISTANCE-1];
generate
for(i=0;i<TAPS_NUM;i=i+1)begin:u1
assign taps[(DWIDTH*(i+1)-1)-:DWIDTH] = idata_r[(i+1)*DISTANCE-1];	
end
endgenerate
endmodule 